package main.java.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
// web3.0增加注解配置方式
@WebFilter("/login.do")
public class LoginFilter1 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.print("LoginFilter1 开始执行");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.print("LoginFilter1 处理拦截逻辑");
        // 拦截需要干的事情，比如记录请求参数，请求编码，校验用户权限


        // 拦截完成后处理下一个过滤器或者servlet
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {
        System.out.print("销毁filter");
    }
}
